function updateDateTime() {
    var container = document.getElementById('datetime');
    var currentDate = new Date();
    var year = currentDate.getFullYear();
    var month = currentDate.getMonth() + 1;
    var day = currentDate.getDate();//声明变量day等于当前日期获取日期天数可返回当前日期
    var hours = currentDate.getHours();
    var minutes = currentDate.getMinutes();
    var seconds = currentDate.getSeconds();
  
    // 格式化月、日、小时、分钟和秒，确保它们始终显示为两位数
    month = (month < 10 ? '0' : '') + month;
    day = (day < 10 ? '0' : '') + day;
    hours = (hours < 10 ? '0' : '') + hours;
    minutes = (minutes < 10 ? '0' : '') + minutes;
    seconds = (seconds < 10 ? '0' : '') + seconds;
  
    // 构建日期时间字符串
    var dateTimeString = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
  
    // 将日期时间字符串设置为容器的文本内容
    container.textContent = dateTimeString;
  }
  
  // 在页面加载时和每隔一秒钟调用updateDateTime函数
  window.onload = function() {
    updateDateTime();
    setInterval(updateDateTime, 1000);//动态时钟//定时调用函数(函数，秒数)
  };